from django.shortcuts import render
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters
from op_drf.pagination import Pagination
from op_drf.response import SuccessResponse, ErrorResponse
from op_drf.dj_utils import set_delete, create_by_serializer
from op_drf.viewsets import CustomModelViewSet
from apps.cus_service.models import Cus_Service
from apps.cus_service.serializers import ReadServiceSerializer,WriteServiceSerializer
# Create your views here.

class ServiceView(CustomModelViewSet):
    """
    处方信息的CRUD
    """
    queryset = Cus_Service.objects.filter(is_delete=False)
    serializer_class = ReadServiceSerializer  # 序列化器
    create_serializer_class = WriteServiceSerializer
    update_serializer_class = WriteServiceSerializer
    # 分页
    pagination_class = Pagination
    # 筛选
    filter_backends = (DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter)
    # filter_class = OrderFilter
    search_fields = ("id", )
    filter_fields = ("id", )
    ordering_fields = ("-id",)
    ordering = ["-create_datetime"]

